<?php
/**
 * User: 1971229701@qq.com
 * Date: 2020/11/3/003
 * Time: 13:09
 */

namespace app\admin\controller;


use app\admin\logic\UploadLogic;
use think\Controller;
use think\Request;

class Upload extends Controller
{
    public function upload(Request $request)
    {
        $files = $request->file('file');
        $logic = new UploadLogic();
        $r = $logic->uploads($files);
        if ($r === false) {
            return apiReturnFail($logic->getError());
        }
        return apiReturnSuc($r);

    }
    public function layui_upload(Request $request)
    {
        $files = $request->file('file');
        $logic = new UploadLogic();
        $r = $logic->uploads($files);
        if ($r === false) {
            return apiReturnFail($logic->getError());
        }
        $data['src'] = $r[0]['file_url'];

        return apiReturnSuc($data,'',0);

    }

}